<template>
    <div class="customizeSet">
        <nly-button-group class="btn-gp mb-2 pr-3">
            <nly-button v-if="source != 'crm'" variant="info" @click="showParentSelect" button-class="mr-2">继承</nly-button>
            <nly-button variant="info" @click="List" button-class="mr-2">刷新</nly-button>
            <nly-button variant="info" @click="AddMenu" button-class="mr-2">新增</nly-button>
            <nly-button variant="info" @click="SaveAllEditItems" button-class="mr-2">全部保存</nly-button>
        </nly-button-group>

        <!-- 列表 -->
        <a-table :columns="columns" :components="components" :data-source="data" :scroll="{ x: 500, y: 600 }" bordered :pagination="false">
            <div title="上下拖动排序" slot="sort" slot-scope="text" style="cursor: move;">{{text}}</div>
            <a-input slot="name" slot-scope="text, record" :maxLength="6" style="height: 28px !important;padding-left:0.5rem !important;" v-model="record.name" @change="ItemEdit(record)"></a-input>
            <a-input-number slot="columnWidth" slot-scope="text, record" v-model="record.columnWidth" :precision="0" :step="10" @change="ItemEdit(record)"></a-input-number>
            <template slot="type" slot-scope="text, record">
                <form-select v-if="record.dataType == 2" v-model="record.type" labelStyle="display: none;" size="small" @change="ItemEdit(record)" :dataList="[
                    { key: '文本', title: '文本' },
                    { key: '下拉', title: '下拉' },
                    { key: '复选', title: '复选' },
                    { key: '单选', title: '单选' },
                    { key: '日期', title: '日期' },
                    { key: '时间', title: '时间' },
                    { key: '整数', title: '整数' },
                    { key: '小数', title: '小数' },
                    { key: '是否', title: '是否' },
                    { key: '区块', title: '区块' },
                ]"></form-select>
                <span v-else>{{text}}</span>
            </template>
            <template slot="val" slot-scope="text, record">
                <form-select v-if=" record.type == '下拉'" title="下拉效果" size="small" :selectStyle="(record.onEdit && (record.dataType == 1 || record.dataType == 2)) ? ' width:80%;':' width:100%;'" labelStyle="display: none;" :dataList="valForFormFN(text)" v-model="record.value">
                    <a slot="actions" v-if="record.onEdit && (record.dataType == 1 || record.dataType == 2)" @click="editItemValFnInRow(record)" style="color:#138496;font-size:1.2rem;display: inline-block;width:20%;">
                        <a-icon type="edit" theme="twoTone" title="编辑下拉框内容" />
                    </a>
                </form-select>
                <form-select v-if=" record.type == '性别'" title="下拉效果" size="small" selectStyle=" width:100%;" labelStyle="display: none;" :dataList="valForFormFN(text)" v-model="record.value">
                </form-select>
                <form-radio v-if="record.type == '单选'" title="单选效果" labelStyle="display: none;" keyPre="menuType" :dataList="valForFormFN(text)" v-model="record.value">
                    <a slot="actions" v-if="record.onEdit && (record.dataType == 1 || record.dataType == 2)" @click="editItemValFnInRow(record)" style="color:#138496;font-size:1.2rem;display: inline-block;width:20%;">
                        <a-icon type="edit" theme="twoTone" title="编辑单选框内容" />
                    </a>
                </form-radio>
                <form-check-box v-if="record.type == '复选'" title="复选效果" labelStyle="display: none;" :dataList="valForCheckBoxFN(text)" v-model="record.value">
                    <a slot="actions" v-if="record.onEdit && (record.dataType == 1 || record.dataType == 2)" @click="editItemValFnInRow(record)" style="color:#138496;font-size:1.2rem;display: inline-block;width:20%;">
                        <a-icon type="edit" theme="twoTone" title="编辑复选框内容" />
                    </a>
                </form-check-box>
                <form-radio v-if="record.type == '是否'" title="是否效果" labelStyle="display: none;" v-model="record.value" keyPre="menuType" :dataList="[
                        { key: '是', title: '是' },
                        { key: '否', title: '否' }
                    ]"></form-radio>
                <form-date-picker v-if="record.type == '日期'" title="日期效果" labelStyle="display: none;" v-model="record.value"></form-date-picker>
                <form-date-picker v-if="record.type == '时间'" title="日期效果" show-time format="YYYY-MM-DD HH:mm" labelStyle="display: none;" v-model="record.value"></form-date-picker>
                <form-input-number v-if="record.type == '整数'" title="整数效果11" labelStyle="display: none;" :precision="0" :step="1" v-model="record.value"></form-input-number>
                <form-input-number v-if="editItem.type == '小数'" title="小数效果" labelStyle="display: none;" :step="0.1" v-model="record.value"></form-input-number>
            </template>

            <!-- PC电脑端 -->
            <template slot="onOff" slot-scope="text, record">
                <a-checkbox :disabled="record.onLocked" v-model="record.onOff" @change="changeOnOff(record)">
                </a-checkbox>
            </template>
            <template slot="onFill" slot-scope="text, record">
                <a-tooltip>
                    <template slot="title" v-if="!record.onEdit">
                        该字段为不可编辑字段
                    </template>
                    <template slot="title" v-else-if="record.dataType > 2">
                        继承字段，不可编辑
                    </template>
                    <template slot="title" v-else-if="record.onLocked">
                        系统锁定，无权限操作
                    </template>

                    <a-checkbox v-model="record.onFill" :disabled="!record.onOff || !record.onEdit || record.onLocked || record.dataType > 2" @change="ItemEdit(record)">
                    </a-checkbox>
                </a-tooltip>

            </template>
            <template slot="isSearch" slot-scope="text, record">
                <a-checkbox v-model="record.isSearch" :disabled="!record.onOff || record.onLocked" @change="ItemEdit(record)">
                </a-checkbox>
            </template>
            <!-- APP移动端 start -->
            <template slot="onAppOff" slot-scope="text, record">
                <a-tooltip>
                    <template slot="title" v-if="isMaxAppOff && !record.onAppOff">
                        APP开启数超过5个，先关闭其他开启状态，再进行操作
                    </template>
                    <template slot="title" v-else-if="record.onLocked">
                        系统锁定，无权限操作
                    </template>
                    <a-checkbox :disabled="record.onLocked || (isMaxAppOff && !record.onAppOff)" v-model="record.onAppOff" @change="changeOnAPPOff(record)">
                    </a-checkbox>
                </a-tooltip>
            </template>
            <template slot="onAppFill" slot-scope="text, record">
                <a-tooltip>
                    <template slot="title" v-if="!record.onEdit">
                        该字段为不可编辑字段
                    </template>
                    <template slot="title" v-else-if="record.dataType > 2">
                        继承字段，不可编辑
                    </template>
                    <template slot="title" v-else-if="record.onLocked">
                        系统锁定，无权限操作
                    </template>

                    <a-checkbox v-model="record.onAppFill" :disabled="!record.onAppOff || !record.onEdit || record.onLocked || record.dataType > 2" @change="ItemEdit(record)">
                    </a-checkbox>
                </a-tooltip>
            </template>
            <template slot="isAppSearch" slot-scope="text, record">
                <a-checkbox v-model="record.isAppSearch" :disabled="!record.onAppOff || record.onLocked" @change="ItemEdit(record)">
                </a-checkbox>
            </template>
            <!-- APP移动端 end -->

            <!-- 操作 -->
            <template slot="operate" slot-scope="text, record, index">
                <div class="row justify-content-md-center">
                    <span class="col"></span>
                    <span class="col-sm-auto col-md-auto col-lg-auto col-xl-auto">
                        <a v-if="record.dataType != 1" href="javascript:;" title="删除" class="mr-1 col-1" @click="Delete(record,index)"><i class="fa fa-trash-alt" style="color: #dd5a43;"></i></a>
                        <a v-if="permissions.includes('NuoNiu')" href="javascript:;" title="改变锁定状态" class="mr-1 col-1" @click="ChangeOnLocked(record)"><i :class="record.onLocked ? 'fa fa-lock':'fa fa-unlock'" style="color:rgb(52, 54, 54);"></i></a>

                    </span>
                    <span class="col"></span>
                </div>
            </template>
        </a-table>
        <!-- modal 弹窗  -->
        <a-modal :title="editItem.id ? '编辑自定义字段' : '新增自定义字段'" :visible="ModalVisible" @ok="onSubmit" @cancel="hideModal">
            <div class="form-inline mb-2" style="display:flex;flex-direction: column;flex:auto;">
                <form-input title="字段名称" rightClass="col-sm-5" labelClass="col-sm-5" :maxLength="6" class="mb-3" :error="formErrors['editItem.name']" :required="true" v-model="editItem.name" labelStyle=""></form-input>
                <form-select title="字段分类" rightClass="col-sm-5" labelClass="col-sm-5" class="mb-3" :error="formErrors['editItem.type']" :required="true" v-model="editItem.type" :dataList="[
                    { key: '文本', title: '文本' },
                    { key: '下拉', title: '下拉' },
                    { key: '复选', title: '复选' },
                    { key: '单选', title: '单选' },
                    { key: '日期', title: '日期' },
                    { key: '时间', title: '时间' },
                    { key: '整数', title: '整数' },
                    { key: '小数', title: '小数' },
                    { key: '是否', title: '是否' },
                    { key: '区块', title: '区块' },
                ]"></form-select>

                <form-select v-if="editItem.type == '下拉'" title="下拉效果" selectStyle="width:80%;" rightClass="col-sm-5" labelClass="col-sm-5" class="mb-3" :dataList="valForForm" v-model="editItem.selectTest">
                    <a slot="actions" @click="editItemValFn()" style="color:#138496;font-size:1.2rem;display: inline-block;width:20%;text-align: center;">
                        <a-icon type="edit" theme="twoTone" title="编辑下拉框内容" />
                    </a>
                </form-select>

                <form-radio v-if="editItem.type == '单选'" title="单选效果" rightClass="col-sm-5" labelClass="col-sm-5" class="mb-3" keyPre="menuType" :dataList="valForForm" v-model="editItem.radioTest">
                    <a slot="actions" @click="editItemValFn()" style="color:#138496;font-size:1.2rem;display: inline-block;width:20%;text-align: center;">
                        <a-icon type="edit" theme="twoTone" title="编辑单选框内容" />
                    </a>
                </form-radio>
                <form-check-box v-if="editItem.type == '复选'" title="复选效果" rightClass="col-sm-5" labelClass="col-sm-5" class="mb-3" :dataList="valForCheckBox" v-model="editItem.checkBoxTest">
                    <a slot="actions" @click="editItemValFn()" style="color:#138496;font-size:1.2rem;display: inline-block;width:20%;text-align: center;">
                        <a-icon type="edit" theme="twoTone" title="编辑复选框内容" />
                    </a>
                </form-check-box>
                <form-radio v-if="editItem.type == '是否'" title="是否效果" rightClass="col-sm-5" labelClass="col-sm-5" class="mb-3" keyPre="menuType" v-model="editItem.onOffTest" :dataList="[
                    { key: '是', title: '是' },
                    { key: '否', title: '否' }
                ]"></form-radio>
                <form-date-picker v-if="editItem.type == '日期'" title="日期效果" rightClass="col-sm-5" labelClass="col-sm-5" class="mb-3" v-model="editItem.dataTest"></form-date-picker>
                <form-date-picker v-if="editItem.type == '时间'" title="时间效果" show-time format="YYYY-MM-DD HH:mm" rightClass="col-sm-5" labelClass="col-sm-5" v-model="editItem.timeTest"></form-date-picker>
                <form-input-number v-if="editItem.type == '整数'" title="整数效果" rightClass="col-sm-5" labelClass="col-sm-5" class="ml-1 mb-1" :precision="0" :step="1" v-model="editItem.zhengshuTest"></form-input-number>
                <form-input-number v-if="editItem.type == '小数'" title="小数效果" rightClass="col-sm-5" labelClass="col-sm-5" class="ml-1 mb-1" :step="0.1" v-model="editItem.xiaoshuTest"></form-input-number>
            </div>
            <div class="form-inline mb-2">
                <nly-col>
                    <!-- FormTextArea -->
                    <form-text-area title="备注信息" rightClass="col-sm-5" labelClass="col-sm-5" v-model="editItem.remarks"></form-text-area>
                </nly-col>
            </div>
        </a-modal>
        <a-modal :visible="listDataModal" :footer="null" title="编辑" size="md" @cancel="hideListDataModal">
            <list-data-manager :list="listData" v-model="editItemVal" :callBack="hideListDataModal">
            </list-data-manager>
        </a-modal>
        <a-modal :visible="selectParentModal" :footer="null" title="继承" size="xl" @cancel="hideParentSelect">
            <select-parent-set v-model="selectedRows" :source="selectSource" :disableKeys="disableKeys">
            </select-parent-set>
            <nly-row style="justify-content: flex-end;">
                <nly-button class="mt-3 mr-3" @click="saveParentSelect" variant="info">保存</nly-button>
                <nly-button class="mt-3" variant="outlineDanger" @click="hideParentSelect">关闭</nly-button>
            </nly-row>
        </a-modal>
    </div>
</template>

<script>
import { DisAbleFirfoxDrag } from "@/utils/browser";
import { mapState } from "vuex";
import Sortable from 'sortablejs';
import { components } from "@/utils/antTableComponents";
import { ListDataManager } from "@/components/Customize";
import { initValidator, checkAll } from "@/utils/validator/validator";
import { clearValue, clearKeys } from "@/utils/tool/object";
import { DefineFieldSave, DefineFieldBatchSave, DefineFieldList, DefineFieldSaveVal, DefineFieldDelete, ChangeOnLocked } from "@/api/crm/set";


// const source = "business";
export default {
    props: {
        source: {
            type: String,
            default: ""
        },
        sourceNameMap: {
            type: Map,
            default: () => new Map()
        }
    },
    components: {
        ListDataManager
    },
    data () {
        const columns = [
            { title: "字段名称", dataIndex: "xx", key: "xx", width: 100 },
            // {
            //   title: "显示名称",
            //   dataIndex: "endTime1",
            //   width: 80,
            //   customRender: (text, record) => {
            //     const key = "endTime1";
            //     const change = e => {
            //       record[key] = e.target.value;
            //     };
            //     return <a-input value={record[key]} onChange={change}></a-input>;
            //   }
            // },
            // {
            //   title: "第2级",
            //   dataIndex: "endTime2",
            //   width: 80,
            //   customRender: (text, record) => {
            //     const key = "endTime2";
            //     const change = e => {
            //       record[key] = e.target.value;
            //     };
            //     return <a-input value={record[key]} onChange={change}></a-input>;
            //   }
            // },
            {
                title: "排序",
                dataIndex: "sort",
                width: 80,
                key: "sort",
                scopedSlots: { customRender: 'sort' },
            },
            {
                title: "默认字段",
                dataIndex: "sysName",
                key: "sysName",
                align: "left",
                // fixed:"left",
                width: 150,
            },
            {
                title: "显示字段",
                dataIndex: "name",
                key: "name",
                width: 150,
                scopedSlots: { customRender: 'name' },
            },
            {
                title: "数据类型",
                dataIndex: "dataType",
                key: "dataType",
                width: 100,
                customRender: (text, row, index) => {
                    let heml = null;
                    switch (text) {
                        case 1: heml = <div>系统字段</div>; break;
                        case 2: heml = <div>完全自定义</div>; break;
                        case 3: heml = <a-tooltip title={`继承自：${row.parentName}`}>继承系统</a-tooltip>; break;
                        case 4: heml = <a-tooltip title={`继承自：${row.parentName}`}>继承自定义</a-tooltip>; break;
                    }
                    return heml;
                }
            },
            //  {
            //   title: "继承字段",
            //   dataIndex: "parentName",
            //   key: "parentName",
            //   width: 150,
            // },
            {
                title: "字段类型",
                dataIndex: "type",
                key: "type",
                width: 100,
                scopedSlots: { customRender: 'type' },
            },
            {
                title: "字段内容",
                dataIndex: "val",
                width: 200,
                key: "val",
                scopedSlots: { customRender: 'val' },
            }
        ];
        //表格 头部 可伸缩
        this.components = components(columns);
        return {
            // sourceNameMap: new Map([["crm","客户"],["linkMan","联系人"]]),
            // source,
            // disableKeys:[],         //继承_已经选择的keys
            selectedRows: [],        //继承_新增的对象数组        
            postData: {},
            listData: [],            //自定义字段的值 数组
            data: [],
            columns,
            editItem: {},
            editItemVal: "",
            formRules: {},          //表单验证规则
            formErrors: {},          //表单错误提示
            ModalVisible: false,
            localEditItem: {},      //本地编辑
            MaxAppOffNum: 5,         //最大APP开启数
            listDataModal: false,
            selectParentModal: false
        }
    },
    created () {
        let { source } = this;
        Object.assign(this.postData, { source })
        const { formRules, formErrors } = this;
        formRules["editItem.name"] = { test: "required" };
        formRules["editItem.type"] = { test: "required" };
        initValidator(this, formRules, formErrors);
    },
    mounted () {
        DisAbleFirfoxDrag();
        this.List();
    },
    computed: {
        valForForm: function () {
            let { editItemVal } = this;
            console.log("valForForm_editItemVal", editItemVal);
            let arr = new Array();
            if (editItemVal) {
                let vals = editItemVal.split(",");
                console.log("valForForm_vals", vals);
                arr = vals.map((item, index, arr) => {
                    return { key: item, title: item };
                })
            }
            console.log("valForForm", arr);
            return arr;
        },
        valForCheckBox: function () {
            let { editItemVal } = this;
            console.log("valForCheckBox_editItemVal", editItemVal);
            let arr = new Array();
            if (editItemVal) {
                let vals = editItemVal.split(",");
                console.log("valForCheckBox_vals", vals);
                arr = vals.map((item, index, arr) => {
                    return { label: item, value: item };
                })
            }
            console.log("valForCheckBox", arr);
            return arr;
        },
        disableKeys: function () {
            return this.data.filter(f => f.dataType == 3 || f.dataType == 4).map(item => item.parentCode);
        },
        selectSource: function () {
            return this.source;
        },
        //是否是最大APP开启数
        isMaxAppOff: function () {
            console.log("计算属性_是否是最大APP开启数")
            const { MaxAppOffNum, data } = this;
            let filter = data.filter(f => f.onAppOff);
            if (!filter) return false;
            return filter.length >= MaxAppOffNum;
        },
        //是否显示继承
        isShowSelectParent: function () {
            const { source } = this;
            return source != 'crm';
        },
        ...mapState({
            permissions: state => state.user.permissions,
        }),
    },
    methods: {
        //添加
        AddMenu () {
            const { formErrors, source } = this;
            Object.assign(this.editItem, { source, dataType: 2 })
            this.editItemVal = this.editItem.val;
            clearKeys(formErrors);
            this.ModalVisible = true;
        },
        editItemValFnInRow (row) {
            this.localEditItem = row;
            this.editItemVal = this.localEditItem.val;
            this.editItemValFn();
        },
        //编辑 自定义字段 的val数组
        editItemValFn () {
            this.listData = this.editItemVal ? this.editItemVal.split(",") : [];
            this.listDataModal = true;
        },

        hideListDataModal () {
            if (this.ModalVisible) {
                this.editItem.val = this.editItemVal;
            } else {
                this.localEditItem.val = this.editItemVal;
                this.localEditItem.isEdit = true;
            }
            this.listDataModal = false;
        },
        // //删除
        Delete (row, index) {
            let _this = this;
            this.$confirm({
                title: '提示',
                content: '您确定要删除该记录吗？',
                onOk () {
                    DefineFieldDelete({ id: row.id })
                        .then(response => {
                            if (response.code === 200) {
                                _this.$message.success("删除成功");
                                //删除 this.data 对象
                                _this.data.splice(index, 1);
                            }
                        });
                },
                onCancel () {
                },
            });
        },
        //  // 获取菜单列表
        printData () {
            console.log("this.data", this.data)
        },
        List () {
            this.data = [];
            const { postData } = this;
            DefineFieldList(postData)
                .then(response => {
                    console.log("获取菜单列表", response);
                    if (response.code === 200) {
                        const { data } = response;
                        this.data = data;
                        if (this.data && this.data.length > 0) {
                            this.drag();
                        }
                    }
                })
                .catch(error => { });
        },

        hideModal () {
            this.ModalVisible = false;
            const { editItem } = this;
            clearValue(editItem);
        },
        //新增 自定义字段
        onSubmit () {
            const { editItem, formRules, formErrors, source } = this;
            //全部校验一次
            checkAll(this, formRules, editItem, formErrors);
            if (Object.keys(formErrors).length > 0) {
                return false;
            }
            Object.assign(this.editItem, {
                source
            });
            DefineFieldSave(this.editItem)
                .then(response => {
                    if (response.code === 200) {
                        this.$message.success("保存成功");
                        //刷新 列表
                        this.List();
                        this.hideModal();
                    }
                })
        },
        //批量保存
        SaveAllEditItems () {
            //1.筛选 isEdit = true 的记录
            let editList = this.data.filter(f => f.isEdit);
            if (!editList || editList.length == 0) {
                this.$info({
                    title: "提示",
                    content: '你没有做任何修改',
                });
                return false;
            }
            DefineFieldBatchSave(editList)
                .then(response => {
                    if (response.code === 200) {
                        this.$message.success("保存成功");
                        //刷新 列表
                        this.List();
                        this.hideModal();
                    }
                })
        },
        // 改变锁定状态
        ChangeOnLocked (record) {
            let postData = { ...record };
            postData.onLocked = !postData.onLocked;
            let _this = this;
            this.$confirm({
                title: '确认',
                content: <span>您确定要{postData.onLocked ? <span style='color:red;'>锁定</span> : <span style='color:green;'>解锁</span>}该字段吗？</span>,
                onOk () {
                    ChangeOnLocked(postData)
                        .then(response => {
                            if (response.code === 200) {
                                _this.$message.success("保存成功");
                                //刷新 列表
                                _this.List();
                            }
                        })
                },
                onCancel () { },
            });
        },
        valForFormFN (editItemVal) {
            let arr = new Array();
            if (editItemVal) {
                let vals = editItemVal.split(",");
                arr = vals.map((item, index, arr) => {
                    return { key: item, title: item };
                })
            }
            return arr;
        },
        valForCheckBoxFN (editItemVal) {
            let arr = new Array();
            if (editItemVal) {
                let vals = editItemVal.split(",");
                arr = vals.map((item, index, arr) => {
                    return { label: item, value: item };
                })
            }
            console.log("valForCheckBoxFN", arr);
            return arr;
        },
        //是否启用PC电脑端
        changeOnOff (row) {
            row.isSearch = row.onOff;
            if (!row.onOff) {
                row.onFill = row.onOff;
            }
            this.ItemEdit(row);
        },
        //是否启用APP移动端
        changeOnAPPOff (row) {
            row.isAppSearch = row.onAppOff;
            if (!row.onAppOff) {
                row.onAppFill = row.onAppOff;
            }
            this.ItemEdit(row);
        },
        //该对象是否更改过
        ItemEdit (row) {
            console.log("ItemEdit_row", row)
            row.isEdit = true;
        },
        // 拖动
        drag () {

            // 首先获取需要拖拽的dom节点
            const el1 = document.querySelectorAll('.customizeSet .ant-table-tbody')[0];
            if (!el1) return false;
            this.isDrag = true;
            Sortable.create(el1, {
                disabled: false, // 是否开启拖拽
                ghostClass: 'sortable-ghost', //拖拽样式
                animation: 150, // 拖拽延时，效果更好看
                group: { // 是否开启跨表拖拽
                    pull: false,
                    put: false
                },
                onEnd: (e) => { // 这里主要进行数据的处理，拖拽实际并不会改变绑定数据的顺序，这里需要自己做数据的顺序更改
                    let arr = this.data; // 获取表数据

                    let removeItem = arr.splice(e.oldIndex, 1)[0];

                    arr.splice(e.newIndex, 0, removeItem); // 数据处理
                    //提前 赋值一个带值的数组（BUG 修复）
                    this.data = [{}];
                    this.$nextTick(function () {
                        this.data = [...arr];
                        this.data.map((item, index) => {
                            item.sort = index + 1;
                            item.isEdit = true;
                        });
                    });
                }
            });
        },
        //弹出 继承 查询窗体
        showParentSelect () {
            this.selectParentModal = true;
        },
        hideParentSelect () {
            this.selectParentModal = false;
            this.selectedRows = [];
        },
        //保存 继承的对象数组
        saveParentSelect () {
            const { selectedRows, sourceNameMap, source } = this;
            let postData = [];
            //1.判断 是否 有选择项

            if (selectedRows.length == 0) {
                this.$info({
                    title: "提示",
                    content: '请选择一个选项',
                });
                return false;
            }
            //2.转换 数据
            selectedRows.forEach((parentItem, index) => {
                let item = { ...parentItem };
                let parentSource = item.source;
                item.parentId = item.id;
                item.dataType = item.dataType + 2;
                item.parentCode = parentSource + "_" + item.code;
                item.parentName = sourceNameMap.get(parentSource) + "_" + item.sysName;
                item.source = source;
                delete item.id;
                postData.push(item);
            });
            DefineFieldBatchSave(postData)
                .then(response => {
                    if (response.code === 200) {
                        this.$message.success("保存成功");
                        //刷新 列表
                        this.List();
                        this.hideParentSelect();
                    }
                })
        }


    }
}
</script>

<style lang="less" scoped>
    ::v-deep {
        .ant-calendar-picker-input {
            height: 28px !important;
        }
    }
    .form-group {
        width: 100%;
    }
    td .form-group {
        margin: 0;
    }
    .test {
        border: 1px solid #ccc;
    }
    .drag-item {
        width: 200px;
        height: 50px;
        line-height: 50px;
        margin: auto;
        position: relative;
        background: #ddd;
        margin-top: 20px;
    }
    .ghostClass {
        opacity: 1;
    }
    .bottom {
        width: 200px;
        height: 50px;
        position: relative;
        background: blue;
        top: 2px;
        left: 2px;
        transition: all 0.5s linear;
    }
    .set-input {
        height: 28px !important;
    }
</style>